<template>
    <el-dialog close-on-press-escape draggable :close-on-click-modal="false" :modal="true" align-center destroy-on-close
        v-model="store.dialog[formIndex].show" :title="store.dialog[props.formIndex].title" width="800">
        <div style="width: 100%;max-height: calc(100vh - 300px);overflow-y: auto;">
            <cform :disabled="1" :form="store.dialog[props.formIndex].form" :value="store.dialog[props.formIndex].value"
                @change="(e) => {
                    console.log(e)
                }"></cform>
        </div>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="handleClose">取消</el-button>
                <el-button @click="handleOK" type="primary">
                    确定
                </el-button>
            </div>
        </template>
    </el-dialog>
</template>

<script setup>
import { ref, reactive, defineProps, computed, watch, onMounted, onBeforeUnmount } from 'vue'

import { useStore } from '../modules/store';
const store = useStore()

import flexBox from './flexBox.vue'

import cform from './cForm.vue';

const props = defineProps({
    formIndex: {
        type: Number,
        default: -1
    }
})

const handleClose = () => {
    store.hideDialog(props.formIndex)
}

const handleOK = () => {
    try {
        store.dialog[props.formIndex].callBack(value, () => {
            handleClose()
        })
    } catch (error) {
        console.log(error)
    }
}

onMounted(async () => {

})

</script>

<style scoped></style>